#ifndef CHAT_SERVER_H
#define CHAT_SERVER_H

#include<nlohmann/json.hpp>
#include"../net/campus_wss_server.h"

using json = nlohmann::json;

const std::string SIGNAL_TYPE_CHAT_JOIN = "chat_join";
const std::string SIGNAL_TYPE_CHAT_MSG = "chat_msg";
const std::string SIGNAL_TYPE_CHAT_RESP_MSG = "chat_resp_msg";

struct ChatServerObserver{
    virtual void handleChatJoin(websocketpp::connection_hdl hdl, json JMsg) = 0;
    virtual void handleChatMsg(websocketpp::connection_hdl hdl, json JMsg) = 0;
};

class CampusChatServer:public CampusWssServer
{   
    
public:
    CampusChatServer(int port, ChatServerObserver* observer);
    virtual ~CampusChatServer() override;

protected:
    virtual void on_open(server *s, websocketpp::connection_hdl hdl) override;
    virtual void on_close(server *s, websocketpp::connection_hdl hdl) override;
    virtual void on_message(server *s, websocketpp::connection_hdl hdl, message_ptr msg) override;
    virtual void on_fail(websocketpp::connection_hdl hdl) override;

private:
    ChatServerObserver* observer_= nullptr;

};
#endif 
